//------------------------------------------------------------------------------
// <copyright file="DateTimeConverter.cs" company="Damian Antonowicz">
//       copyright © 2010 Damian Antonowicz
// </copyright>
// <author>Damian Antonowicz</author>
// <email>poczta@damianantonowicz.pl</email>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Diagnostics;
using DAnton.Utilities.Helpers;
using System.Threading;

namespace DotBeer.UI.WPFClient
{
    public class DateTimeConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DateTime date = (DateTime)value;
            Thread.CurrentThread.CurrentCulture = WMIHelper.GetOperatingSystemCultureInfo();
            string dateString = "";

            if (date == DateTime.MinValue)
                dateString = "unknown";
            else
                dateString = String.Format("{0} {1}", date.ToLongTimeString(), date.ToShortDateString());

            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            return dateString;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
